/**  
* @Title: GlobalAction.java
* @Package org.mtons.controller
* @Description: TODO
* @author ma jinjian  
* @date 2016年1月17日 下午6:14:30
* @version V1.0  
*/ 
package cn.net.mtons.web;

import java.util.ArrayList;
import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import cn.net.mtons.model.entity.vo.AjaxResultVO;
import cn.net.mtons.model.entity.vo.MainMenuVO;
import cn.net.mtons.model.entity.vo.SystemUserVO;
import cn.net.mtons.model.entity.vo.TreeMenuVO;
import cn.net.mtons.web.Application;
import cn.net.mtons.web.BasicAction;

/**
 * @ClassName: GlobalAction
 * @Description: 全局Action
 * @author ma jinjian
 * @date 2016年1月17日 下午6:14:30
 *
 */
@RequestMapping("/global")
public class GlobalAction extends BasicAction {

	@Autowired
	private Application app;
	
	@SuppressWarnings("unused")
	private static Logger logger = Logger.getLogger("command");
	
	@RequestMapping(value="/skipLogin",method=RequestMethod.GET)
	public String skipLogin() {
		return "/MA_000_00/main/jsp/main.jsp";
	}
	
	@RequestMapping(value="/debugLogin", method=RequestMethod.GET) 
	public String debugLogin() {
		return "/MA_000_00/main/jsp/main.jsp";
	}
	
	@ResponseBody
	@RequestMapping(value="/login", method=RequestMethod.POST)
	public AjaxResultVO login(HttpServletRequest request){
		
		AjaxResultVO vo = new AjaxResultVO();
		
		SystemUserVO user = new SystemUserVO();
		user.setAccountNumber("majinjian");
		user.setUserId("majinjian");
		user.setUserName("马金健");
		
		List<MainMenuVO> main = new ArrayList<MainMenuVO>();
		
		MainMenuVO menu1 = new MainMenuVO("账号管理");
		menu1.addTreeMenu(new TreeMenuVO("账户管理", "MTONS_001", "Account", true, false));
		main.add(menu1);
		
		MainMenuVO menu2 = new MainMenuVO("部门管理");
		menu2.addTreeMenu(new TreeMenuVO("部门管理", "MTONS_002", "Department", true, false));
		main.add(menu2);
		
		MainMenuVO menu3 = new MainMenuVO("权限管理");
		menu3.addTreeMenu(new TreeMenuVO("权限管理", "MTONS_003", "Authority", true, false));
		main.add(menu3);
		
		MainMenuVO menu4 = new MainMenuVO("会议管理");
		menu4.addTreeMenu(new TreeMenuVO("会议管理", "MTONS_004", "Meeting", true, false));
		main.add(menu4);
		
		MainMenuVO menu5 = new MainMenuVO("审批管理");
		menu5.addTreeMenu(new TreeMenuVO("审批管理", "MTONS_005", "Examine", true, false));
		main.add(menu5);
		
		user.setMenu(main);
		
		vo.success();
		vo.setData(user);
		
		return vo;
	}
}
